package done.normal_501_600;

import com.study.common.TreeNode;
import org.junit.Test;

import static com.study.util.LogUtil.info;

/**
 * 513. Find Bottom Left Tree Value 找树左下角的值
 * <p>
 * 给定一个二叉树，在树的最后一行找到最左边的值。
 * 示例 1:
 * 输入:
 * 2
 * / \
 * 1   3
 * <p>
 * 输出: 1
 * <p>
 * 示例 2:
 * 输入:
 * 1
 * / \
 * 2   3
 * /   / \
 * 4   5   6
 * /
 * 7
 * <p>
 * 输出: 7
 * <p>
 * 2019-05-19 14:33
 **/
@SuppressWarnings("all")
public class FindBottomLeftTreeValue {

    public int findBottomLeftValue(TreeNode root) {
        // 190519 first
        return -1;
    }

    @Test
    public void test() {
        info(findBottomLeftValue(new TreeNode(1,
                new TreeNode(2,
                        4), new TreeNode(3, new TreeNode(
                5,
                7),
                6))));
    }
}































/*
int maxh = -1;
int val = -1;

public int findBottomLeftValue(TreeNode root) {
    dfs(root, 0);
    return val;
}

void dfs(TreeNode root, int height) {
    if (root == null)
        return;

    // 大于maxh的只能有一次，因为后面就等于了
    if (height > maxh) {
        val = root.val;
        maxh = height;
    }

    if (root.left != null)
        dfs(root.left, height + 1);

    if (root.right != null)
        dfs(root.right, height + 1);
}
*/